<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Packages</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Packages' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../intern.html">Inter Modules</a></li><li><a href="index.html">bytecode</a></li><li><a href="index.html#2">Chapter 2: The Trees</a></li><li><b>Packages</b></li></ul></div>
<p class="purpose">To manage packages of inter code.</p>

<ul class="toc"><li><a href="2-pck.html#SP1">&#167;1. Introduction</a></li><li><a href="2-pck.html#SP7">&#167;7. Naming</a></li><li><a href="2-pck.html#SP8">&#167;8. Type</a></li><li><a href="2-pck.html#SP9">&#167;9. Scope</a></li><li><a href="2-pck.html#SP12">&#167;12. Packages as containers</a></li><li><a href="2-pck.html#SP13">&#167;13. Flags</a></li><li><a href="2-pck.html#SP19">&#167;19. Subpackages and URLs</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Introduction.</b>As noted in <a href="P-wtmd.html" class="internal">What This Module Does</a>, the content in a tree is structured by
being placed in a nested hierarchy of boxes called "packages".
</p>

<p class="commentary">A package has a location in the tree defined by its <span class="extract"><span class="extract-syntax">package_head</span></span> node: this
will be a <span class="extract"><span class="extract-syntax">PACKAGE_IST</span></span> instruction. Every package has a name and a type. For
example, suppose we have:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    A</span>
<span class="plain-syntax">        B</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">package</span><span class="plain-syntax"> gadgets _paraphernalia          &lt;-- package_head node</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">symbol</span><span class="plain-syntax"> </span><span class="reserved-syntax">private</span><span class="plain-syntax"> </span><span class="reserved-syntax">misc</span><span class="plain-syntax"> ^is_electrical</span>
<span class="plain-syntax">        C</span>
<span class="plain-syntax">            D</span>
<span class="plain-syntax">        E</span>
<span class="plain-syntax">    F</span>
<span class="plain-syntax">    G</span>
</pre>
<p class="commentary">Here the Inter instructions C, D and E are the content of the package, which
is called "gadgets" and has the type <span class="extract"><span class="extract-syntax">_paraphernalia</span></span>. Instructions A, B, F,
G , along with the <span class="extract"><span class="extract-syntax">package</span></span> instruction itself, belong to the wider context. The
symbol name <span class="extract"><span class="extract-syntax">^is_electrical</span></span> is visible to C, D and E, but not to A, B, F,
and G: it belongs to the "scope" of the <span class="extract"><span class="extract-syntax">gadgets</span></span> package, and is recorded
in its private symbols table.
</p>

<p class="commentary">Note that the package head node is outside the package. So although the name
<span class="extract"><span class="extract-syntax">gadgets</span></span> is also a symbol, it belongs to the wider scope (the A, B, ...
scope): it does not appear in the package's own symbols table, and in that
sense a package cannot see its own name.
</p>

<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>Clearly a package involves more data than can be recorded in the <span class="extract"><span class="extract-syntax">PACKAGE_IST</span></span>
instruction alone, so each package has a corresponding <a href="2-pck.html#SP2" class="internal">inter_package</a> structure.
That structure is a resource belonging to the tree, so it's included in the
resource list of the tree's warehouse, and has a resource ID within it. See
<a href="2-tw.html" class="internal">The Warehouse</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">package_head</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">package_scope</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">package_flags</span><span class="plain-syntax">; </span><span class="comment-syntax"> a bitmap of the </span><span class="extract"><span class="extract-syntax">*_PACKAGE_FLAG</span></span><span class="comment-syntax"> bits</span>
<span class="plain-syntax">    </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">resource_ID</span><span class="plain-syntax">; </span><span class="comment-syntax"> within the warehouse for the tree holding the package</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure inter_package is accessed in 2/it, 2/st, 2/trn, 3/iibf, 4/tpc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Do not call this directly to make a new package: it needs the resource ID <span class="extract"><span class="extract-syntax">n</span></span>
to exist already, and that has to be allocated. So instead you could call
<a href="2-tw.html#SP9" class="internal">InterWarehouse::create_package</a>, which calls this. But in fact what you
should really do is just to generate a <span class="extract"><span class="extract-syntax">PACKAGE_IST</span></span> instruction, because
the package needs its head node too: everything will then automatically work.
See <a href="4-tpc.html#SP3" class="internal">PackageInstruction::new</a> for how to do that.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">InterPackage::new</span></span>:<br/>The Warehouse - <a href="2-tw.html#SP9">&#167;9</a><br/>Inter in Binary Files - <a href="3-iibf.html#SP10_1_3_2_3">&#167;10.1.3.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_head</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_scope</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">resource_ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::warehouse_ID</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">resource_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b><a href="2-pck.html#SP2" class="internal">inter_package</a> structures and <span class="extract"><span class="extract-syntax">PACKAGE_IST</span></span> instruction nodes correspond
to each other in a way which exactly matches, except for the root package.
For all other packages, these two operations are inverse to each other:
</p>

<ul class="items"><li>&#9679; To get from a head node to its package, call <a href="4-tpc.html#SP9" class="internal">PackageInstruction::at_this_head</a>.
</li><li>&#9679; To get from a package to its head node, call <a href="2-pck.html#SP4" class="internal">InterPackage::head</a>.
</li></ul>
<p class="commentary">The root package is a very special one-off case &mdash; see <a href="2-it.html" class="internal">Inter Trees</a>: it
does not originate from any package instruction because it represents the
outermost box, that is, the top level of the hierarchy.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::head</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">InterPackage::head</span></span>:<br/><a href="2-pck.html#SP5">&#167;5</a>, <a href="2-pck.html#SP6">&#167;6</a>, <a href="2-pck.html#SP11">&#167;11</a><br/>Inter Trees - <a href="2-it.html#SP8">&#167;8</a>, <a href="2-it.html#SP9">&#167;9</a><br/>Bookmarks - <a href="2-bkm.html#SP4">&#167;4</a>, <a href="2-bkm.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-pck.html#SP15" class="function-link"><span class="function-syntax">InterPackage::is_a_root_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_head</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::tree</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">InterPackage::tree</span></span>:<br/>Bookmarks - <a href="2-bkm.html#SP5">&#167;5</a><br/>The Warehouse - <a href="2-tw.html#SP5">&#167;5</a><br/>Symbols - <a href="2-sym.html#SP20">&#167;20</a>, <a href="2-sym.html#SP21">&#167;21</a>, <a href="2-sym.html#SP22">&#167;22</a><br/>The Wiring - <a href="2-tw2.html#SP12">&#167;12</a><br/>Transmigration - <a href="2-trn.html#SP3_1">&#167;3.1</a>, <a href="2-trn.html#SP5_2_2">&#167;5.2.2</a><br/>Inter in Text Files - <a href="3-iitf.html#SP5_1">&#167;5.1</a>, <a href="3-iitf.html#SP7_1">&#167;7.1</a><br/>Inter Value Pairs - <a href="3-ivp.html#SP13">&#167;13</a><br/>Inter Data Types - <a href="3-idt.html#SP18_12">&#167;18.12</a><br/>Metadata - <a href="3-mtd.html#SP6_1">&#167;6.1</a><br/>The Package Construct - <a href="4-tpc.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_head</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">tree</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The following function relies on an important rule of the road: that the
parent node of a package head node must be another package head node (except
of course at the very top of the tree).
</p>

<p class="commentary">It follows that we can get from a package to its next outermost package (its
"parent") by taking its head node, taking the node-parent of that, and then
finding the package with that head.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::parent</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">InterPackage::parent</span></span>:<br/><a href="2-pck.html#SP19">&#167;19</a><br/>Symbols Tables - <a href="2-st.html#SP18">&#167;18</a><br/>Symbols - <a href="2-sym.html#SP3">&#167;3</a><br/>Transmigration - <a href="2-trn.html#SP3">&#167;3</a>, <a href="2-trn.html#SP3_1">&#167;3.1</a>, <a href="2-trn.html#SP3_3">&#167;3.3</a><br/>Inter in Binary Files - <a href="3-iibf.html#SP10_2_3_2_3">&#167;10.2.3.2.3</a><br/>Inter in Text Files - <a href="3-iitf.html#SP3_2">&#167;3.2</a><br/>The Package Construct - <a href="4-tpc.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-pck.html#SP15" class="function-link"><span class="function-syntax">InterPackage::is_a_root_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP4" class="function-link"><span class="function-syntax">InterPackage::head</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="2-it.html#SP4" class="function-link"><span class="function-syntax">InterTree::parent</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-tpc.html#SP9" class="function-link"><span class="function-syntax">PackageInstruction::at_this_head</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>The baseline level for a package is the level in the hierarchy of its root
node, or is 0 for the root package.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::baseline</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">InterPackage::baseline</span></span>:<br/>Bookmarks - <a href="2-bkm.html#SP7">&#167;7</a><br/>Transmigration - <a href="2-trn.html#SP3_2">&#167;3.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-pck.html#SP15" class="function-link"><span class="function-syntax">InterPackage::is_a_root_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-in.html#SP13" class="function-link"><span class="function-syntax">Inode::get_level</span></a><span class="plain-syntax">(</span><a href="2-pck.html#SP4" class="function-link"><span class="function-syntax">InterPackage::head</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Naming.</b>The name of a package is by definition the name of its symbol, which can be
extracted from the bytecode of its <span class="extract"><span class="extract-syntax">package</span></span> instruction, stored at the head-node.
(And the root package, which has no head-node, has the empty name.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::name</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">InterPackage::name</span></span>:<br/><a href="2-pck.html#SP19">&#167;19</a><br/>Symbols Tables - <a href="2-st.html#SP18">&#167;18</a><br/>Transmigration - <a href="2-trn.html#SP3_2">&#167;3.2</a>, <a href="2-trn.html#SP3_3">&#167;3.3</a><br/>Inter Constructs - <a href="3-ic.html#SP5">&#167;5</a><br/>Inter in Binary Files - <a href="3-iibf.html#SP10_2_3_2_3">&#167;10.2.3.2.3</a><br/>The Package Construct - <a href="4-tpc.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="4-tpc.html#SP9" class="function-link"><span class="function-syntax">PackageInstruction::name_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Type.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::type</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">InterPackage::type</span></span>:<br/>Inter Trees - <a href="2-it.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_head</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-tpc.html#SP10" class="function-link"><span class="function-syntax">PackageInstruction::get_type_of</span></a><span class="plain-syntax">(</span><a href="2-in.html#SP6" class="function-link"><span class="function-syntax">Inode::tree</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">), </span><span class="identifier-syntax">D</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Scope.</b>The symbols table of local names within scope for the package.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::set_scope</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">InterPackage::set_scope</span></span>:<br/>Inter Trees - <a href="2-it.html#SP2_1">&#167;2.1</a><br/>Inter in Binary Files - <a href="3-iibf.html#SP10_1_3_2_3">&#167;10.1.3.2.3</a><br/>The Package Construct - <a href="4-tpc.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"null package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_scope</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_package</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>This function is the inverse of <a href="2-st.html#SP3" class="internal">InterSymbolsTable::package</a>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::scope</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">InterPackage::scope</span></span>:<br/><a href="2-pck.html#SP11">&#167;11</a><br/>Inter Trees - <a href="2-it.html#SP3">&#167;3</a><br/>Bookmarks - <a href="2-bkm.html#SP7">&#167;7</a><br/>Symbols Tables - <a href="2-st.html#SP14">&#167;14</a>, <a href="2-st.html#SP15">&#167;15</a>, <a href="2-st.html#SP16">&#167;16</a>, <a href="2-st.html#SP19">&#167;19</a><br/>The Wiring - <a href="2-tw2.html#SP11">&#167;11</a>, <a href="2-tw2.html#SP12">&#167;12</a>, <a href="2-tw2.html#SP14">&#167;14</a>, <a href="2-tw2.html#SP16">&#167;16</a>, <a href="2-tw2.html#SP17">&#167;17</a><br/>Transmigration - <a href="2-trn.html#SP3_5">&#167;3.5</a>, <a href="2-trn.html#SP5_2_2">&#167;5.2.2</a>, <a href="2-trn.html#SP6">&#167;6</a><br/>Inter Constructs - <a href="3-ic.html#SP7">&#167;7</a><br/>Inter in Text Files - <a href="3-iitf.html#SP7">&#167;7</a><br/>Verifying Inter - <a href="3-vi.html#SP1_2">&#167;1.2</a>, <a href="3-vi.html#SP2">&#167;2</a>, <a href="3-vi.html#SP4">&#167;4</a><br/>Inter Value Pairs - <a href="3-ivp.html#SP13">&#167;13</a>, <a href="3-ivp.html#SP22">&#167;22</a><br/>Inter Data Types - <a href="3-idt.html#SP14">&#167;14</a><br/>Metadata - <a href="3-mtd.html#SP3">&#167;3</a><br/>The Constant Construct - <a href="4-tcc2.html#SP8">&#167;8</a><br/>The Package Construct - <a href="4-tpc.html#SP8">&#167;8</a>, <a href="4-tpc.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_scope</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>The following searches recursively: i.e., not just the package's scope, but
also the scope of all its subpackages. This is a slow operation, but there is
no need for it to be fast: it is used only very sparingly.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::find_symbol_slowly</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">found</span><span class="plain-syntax"> = </span><a href="2-st.html#SP7" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name</span></a><span class="plain-syntax">(</span><a href="2-pck.html#SP10" class="function-link"><span class="function-syntax">InterPackage::scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">), </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">found</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">found</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP4" class="function-link"><span class="function-syntax">InterPackage::head</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_THROUGH_INTER_CHILDREN</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">D</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-in.html#SP13" class="function-link"><span class="function-syntax">Inode::is</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="constant-syntax">PACKAGE_IST</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">Q</span><span class="plain-syntax"> = </span><a href="4-tpc.html#SP9" class="function-link"><span class="function-syntax">PackageInstruction::at_this_head</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">found</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP11" class="function-link"><span class="function-syntax">InterPackage::find_symbol_slowly</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">Q</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">found</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">found</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Packages as containers.</b>For any node, the innermost package containing that node is called its
"container"; but this is null at the root of the tree, i.e., it is never
equal to the special root package.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::container</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">InterPackage::container</span></span>:<br/>Transmigration - <a href="2-trn.html#SP3_3">&#167;3.3</a><br/>Verifying Inter - <a href="3-vi.html#SP1_2_1">&#167;1.2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><a href="2-in.html#SP6" class="function-link"><span class="function-syntax">Inode::get_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-pck.html#SP15" class="function-link"><span class="function-syntax">InterPackage::is_a_root_package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::scope_of</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">InterPackage::scope_of</span></span>:<br/>Symbols Tables - <a href="2-st.html#SP14">&#167;14</a><br/>Inter in Text Files - <a href="3-iitf.html#SP10">&#167;10</a>, <a href="3-iitf.html#SP12_13">&#167;12.13</a><br/>Inter Value Pairs - <a href="3-ivp.html#SP13">&#167;13</a><br/>The Constant Construct - <a href="4-tcc2.html#SP10">&#167;10</a><br/>The Typename Construct - <a href="4-ttc.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP12" class="function-link"><span class="function-syntax">InterPackage::container</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_scope</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-in.html#SP6" class="function-link"><span class="function-syntax">Inode::globals</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Flags.</b>Packages with special behaviour are marked with flags. (Flags can also be used
as temporary markers when fooling with Inter code during pipeline processing.)
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">ROOT_PACKAGE_FLAG</span><span class="plain-syntax">          </span><span class="constant-syntax">1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">FUNCTION_BODY_PACKAGE_FLAG</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">LINKAGE_PACKAGE_FLAG</span><span class="plain-syntax">       </span><span class="constant-syntax">4</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">PERSISTENT_PACKAGE_FLAGS</span><span class="plain-syntax">   </span><span class="constant-syntax">255</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">USED_PACKAGE_FLAG</span><span class="plain-syntax">          </span><span class="constant-syntax">256</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">MARK_PACKAGE_FLAG</span><span class="plain-syntax">          </span><span class="constant-syntax">512</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::get_flag</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">f</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">f</span><span class="plain-syntax">)?</span><span class="identifier-syntax">TRUE:FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::set_flag</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">f</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> | </span><span class="identifier-syntax">f</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::clear_flag</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">InterPackage::clear_flag</span></span>:<br/><a href="2-pck.html#SP18">&#167;18</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">f</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">f</span><span class="plain-syntax">) </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> - </span><span class="identifier-syntax">f</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>These are used when reading and writing binary Inter files: because of course
the data in the flags must persist when files are written out and read back again.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::get_persistent_flags</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">InterPackage::get_persistent_flags</span></span>:<br/>Inter in Binary Files - <a href="3-iibf.html#SP10_2_3_2_3">&#167;10.2.3.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; </span><span class="constant-syntax">PERSISTENT_PACKAGE_FLAGS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::set_persistent_flags</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">InterPackage::set_persistent_flags</span></span>:<br/>Inter in Binary Files - <a href="3-iibf.html#SP10_1_3_2_3">&#167;10.1.3.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no package"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; (~</span><span class="constant-syntax">PERSISTENT_PACKAGE_FLAGS</span><span class="plain-syntax">)) | (</span><span class="identifier-syntax">x</span><span class="plain-syntax"> &amp; </span><span class="constant-syntax">PERSISTENT_PACKAGE_FLAGS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>The <span class="extract"><span class="extract-syntax">ROOT_PACKAGE_FLAG</span></span> is given only to the root package of a tree, so there
will only ever be one of these in any given tree.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::is_a_root_package</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">InterPackage::is_a_root_package</span></span>:<br/><a href="2-pck.html#SP4">&#167;4</a>, <a href="2-pck.html#SP5">&#167;5</a>, <a href="2-pck.html#SP6">&#167;6</a>, <a href="2-pck.html#SP12">&#167;12</a><br/>Inter Constructs - <a href="3-ic.html#SP6">&#167;6</a><br/>Inter in Text Files - <a href="3-iitf.html#SP3_2">&#167;3.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; </span><span class="constant-syntax">ROOT_PACKAGE_FLAG</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::mark_as_a_root_package</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">InterPackage::mark_as_a_root_package</span></span>:<br/>Inter Trees - <a href="2-it.html#SP2_1">&#167;2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> |= </span><span class="constant-syntax">ROOT_PACKAGE_FLAG</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>The <span class="extract"><span class="extract-syntax">FUNCTION_BODY_PACKAGE_FLAG</span></span> is given to function bodies. Note that the code
of each function always occupies a single package, which contains nothing else.
Subsidiary parts of the function &mdash; what are called "code blocks" in C, like
loop bodies &mdash; are not subpackages of this: a code package has no subpackages.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::is_a_function_body</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">InterPackage::is_a_function_body</span></span>:<br/>Inter Constructs - <a href="3-ic.html#SP5">&#167;5</a><br/>The Package Construct - <a href="4-tpc.html#SP5">&#167;5</a>, <a href="4-tpc.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; </span><span class="constant-syntax">FUNCTION_BODY_PACKAGE_FLAG</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::mark_as_a_function_body</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">InterPackage::mark_as_a_function_body</span></span>:<br/>The Package Construct - <a href="4-tpc.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> |= </span><span class="constant-syntax">FUNCTION_BODY_PACKAGE_FLAG</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b>The <span class="extract"><span class="extract-syntax">LINKAGE_PACKAGE_FLAG</span></span> is given only to a few top-level packages which
behave differently during the transmigration process used in linking trees
together. This is not the place to explain: see <a href="../building-module/1-ls.html" class="internal">Large-Scale Structure (in building)</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::is_a_linkage_package</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">InterPackage::is_a_linkage_package</span></span>:<br/>Transmigration - <a href="2-trn.html#SP5_2">&#167;5.2</a>, <a href="2-trn.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> &amp; </span><span class="constant-syntax">LINKAGE_PACKAGE_FLAG</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::mark_as_a_linkage_package</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">InterPackage::mark_as_a_linkage_package</span></span>:<br/>The Package Construct - <a href="4-tpc.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">pack</span><span class="plain-syntax">) </span><span class="identifier-syntax">pack</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_flags</span><span class="plain-syntax"> |= </span><span class="constant-syntax">LINKAGE_PACKAGE_FLAG</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b><span class="extract"><span class="extract-syntax">MARK_PACKAGE_FLAG</span></span> is ephemeral and typically used to mark that something
has already been done on a given package, so that it won't be done twice.
At the start of such a process, call this.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::unmark_all</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="2-pck.html#SP13" class="function-link"><span class="function-syntax">InterPackage::clear_flag</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pack</span><span class="plain-syntax">, </span><span class="constant-syntax">MARK_PACKAGE_FLAG</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Subpackages and URLs.</b>A package is uniquely identifiable (within its tree) by its textual URL, in the
form <span class="extract"><span class="extract-syntax">/main/whatever/example1/this</span></span>. The following goes from an <a href="2-pck.html#SP2" class="internal">inter_package</a>
to its URL, which is particularly handy for the debugging log:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::write_URL</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">InterPackage::write_URL</span></span>:<br/>Inter Constructs - <a href="3-ic.html#SP7">&#167;7</a><br/>Metadata - <a href="3-mtd.html#SP8">&#167;8</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) { </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;none&gt;"</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">chain</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_URL_SYMBOL_NAME_DEPTH</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">chain_length</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">chain_length</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_URL_SYMBOL_NAME_DEPTH</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"package nesting too deep"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">chain</span><span class="plain-syntax">[</span><span class="identifier-syntax">chain_length</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP5" class="function-link"><span class="function-syntax">InterPackage::parent</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=</span><span class="identifier-syntax">chain_length</span><span class="plain-syntax">-1; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&gt;=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">--) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"/%S"</span><span class="plain-syntax">, </span><a href="2-pck.html#SP7" class="function-link"><span class="function-syntax">InterPackage::name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">chain</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterPackage::log</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">InterPackage::log</span></span>:<br/>Bytecode Module - <a href="1-bm.html#SP3_4">&#167;3.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vp</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">vp</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="2-pck.html#SP19" class="function-link"><span class="function-syntax">InterPackage::write_URL</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">pack</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b>The other direction, parsing a URL into its corresponding <a href="2-pck.html#SP2" class="internal">inter_package</a>, is
necessarily slower, and we perform it as little as possible. The following looks
for a subpackage called <span class="extract"><span class="extract-syntax">name</span></span> within the parent package <span class="extract"><span class="extract-syntax">P</span></span>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::from_name</span><button class="popup" onclick="togglePopup('usagePopup23')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup23">Usage of <span class="code-font"><span class="function-syntax">InterPackage::from_name</span></span>:<br/><a href="2-pck.html#SP21">&#167;21</a><br/>Symbols Tables - <a href="2-st.html#SP19">&#167;19</a><br/>The Package Construct - <a href="4-tpc.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_head</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">tree</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">root_package</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"main"</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">LargeScale::main_package_if_it_exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_head</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">tree</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-st.html#SP8" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name_not_following</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">package_scope</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-tpc.html#SP9" class="function-link"><span class="function-syntax">PackageInstruction::at_this_head</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">definition</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. </b>And that is the key tool needed for the following. Note that if there is an
initial slash, the URL is absolute, with respect to the top of the tree; and
otherwise it is construed as a single name. (So searching for <span class="extract"><span class="extract-syntax">this/that</span></span>
could never succeed: without the initial slash, this would have to be the name
of a single package, and slashes can't be part of package names.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">InterPackage::from_URL</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get_first_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">) == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">at_P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">root_package</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">at_P</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP20" class="function-link"><span class="function-syntax">InterPackage::from_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">at_P</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at_P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pack</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP20" class="function-link"><span class="function-syntax">InterPackage::from_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">at_P</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">pack</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-pck.html#SP20" class="function-link"><span class="function-syntax">InterPackage::from_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">root_package</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="2-tw.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-bm.html">1</a></li><li class="progresscurrentchapter">2</li><li class="progresssection"><a href="2-it.html">it</a></li><li class="progresssection"><a href="2-in.html">in</a></li><li class="progresssection"><a href="2-bkm.html">bkm</a></li><li class="progresssection"><a href="2-np.html">np</a></li><li class="progresssection"><a href="2-tw.html">tw</a></li><li class="progresscurrent">pck</li><li class="progresssection"><a href="2-inl.html">inl</a></li><li class="progresssection"><a href="2-st.html">st</a></li><li class="progresssection"><a href="2-sym.html">sym</a></li><li class="progresssection"><a href="2-ann.html">ann</a></li><li class="progresssection"><a href="2-tw2.html">tw2</a></li><li class="progresssection"><a href="2-trn.html">trn</a></li><li class="progresschapter"><a href="3-ic.html">3</a></li><li class="progresschapter"><a href="4-tcc.html">4</a></li><li class="progresschapter"><a href="5-tac.html">5</a></li><li class="progresschapter"><a href="6-tpc.html">6</a></li><li class="progressnext"><a href="2-inl.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

